package com.project.bean;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;

public class UserBean {
    /**编号*/
    private  int id;
    /**姓名*/
    @NotBlank(message = "用户名不能为空")
    @Pattern(regexp ="[0-9A-Za-z]{2,}",message = "请输入两位以上的数字或字母")
    private String name;
    /**性别*/
    @NotBlank(message = "不能为空")
    @Pattern(regexp = "[男女]",message = "男或女")
    private String sex;
    /**工资*/
    @NotBlank(message = "不能为空")
    @Pattern(regexp = "[1-9]\\d*",message = "工资只能是数字")
    private int money;
    /**生日*/
    @NotBlank(message = "不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    public int getId() {
        return id;
    }

    public UserBean() {
    }

    public UserBean(String name, String sex, int money, LocalDate birthday) {
        this.name = name;
        this.sex = sex;
        this.money = money;
        this.birthday = birthday;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", money=" + money +
                ", birthday=" + birthday +
                "}\n";
    }
}
